package handling;

import constants.ServerConfig;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;
import tools.FileoutputUtil;
import tools.StringUtil;

public enum SendPacketOpcode implements WritableIntValueHolder {

    LP_CheckPasswordResult,
    LP_WorldInformation,
    LP_LatestConnectedWorld,
    LP_RecommendWorldMessage,
    LP_SetPhysicalWorldID,
    LP_SelectWorldResult,
    LP_SelectCharacterResult,
    LP_AccountInfoResult,
    LP_CheckDuplicatedIDResult,
    LP_CreateNewCharacterResult,
    LP_DeleteCharacterResult,
    LP_MigrateCommand,
    LP_AliveReq,
    LP_AuthenCodeChanged,
    LP_CheckSPWExistResult,
    LP_AlbaRequestResult,
    CHOOSE_GENDER,
    GENDER_SET,
    HACKSHIELD_REQUEST,
    FORCED_CHANGE_CHAR_NAME,
    FORCED_CHANGE_CHAR_NAME_NOTICE,
    SERVERSTATUS,
    LOGIN_AUTH,
    SHOW_MAPLESTORY,
    LP_ClientPacketOpocde,
    LP_ChangeSPWResult,
    LP_CheckSPWResult,
    REMOVE_BG_LAYER,
    CHANGE_BACKGROUND,
    LP_SetMapObjectVisible,
    RESET_SCREEN,
    LP_InventoryOperation,
    LP_InventoryGrow,
    LP_StatChanged,
    LP_TemporaryStatSet,
    LP_TemporaryStatReset,
    LP_ForcedStatSet,
    LP_ForcedStatReset,
    LP_ChangeSkillRecordResult,
    LP_ChangeStealMemoryResult,
    LP_MobDropMesoPickup,
    LP_UserDamageOnFallingCheck,
    LP_ResultStealSkillList,
    LP_ExclRequest,
    LP_GivePopularityResult,
    LP_Message,
    LP_MemoResult,
    LP_MapTransferResult,
    LP_AntiMacroResult,
    LP_AntiMacroBombResult,
    LP_ClaimResult,
    LP_SetClaimSvrAvailableTime,
    LP_ClaimSvrStatusChanged,
    LP_SetTamingMobInfo,
    LP_QuestClear,
    LP_EntrustedShopCheckResult,
    LP_SkillLearnItemResult,
    LP_SkillResetItemResult,
    LP_AbilityResetItemResult,
    LP_ExpConsumeResetItemResult,
    LP_ExpItemGetResult,
    LP_CharSlotIncItemResult,
    LP_CharRenameItemResult,
    LP_GatherItemResult,
    LP_SortItemResult,
    LP_CharacterInfo,
    LP_PartyResult,
    LP_PartyMemberCandidateResult,
    LP_UrusPartyMemberCandidateResult,
    LP_PartyCandidateResult,
    LP_UrusPartyResult,
    LP_ExpeditionNoti,
    LP_FriendResult,
    LP_GuildRequest,
    LP_GuildResult,
    LP_AllianceResult,
    LP_TownPortal,
    MECH_PORTAL,
    LP_BroadcastMsg,
    LP_AswanTimeTableState,
    LP_IncubatorResult,
    LP_IncubatorHotItemResult,
    LP_ShopScannerResult,
    LP_ShopLinkResult,
    LP_MarriageRequest,
    LP_MarriageResult,
    LP_WeddingGiftResult,
    LP_MarriedPartnerMapTransfer,
    LP_CashPetFoodResult,
    LP_CashPetSkillSettingResult,
    LP_CashLookChangeResult,
    LP_SetWeekEventMessage,
    LP_SetPotionDiscountRate,
    LP_BridleMobCatchFail,
    LP_ImitatedNPCResult,
    LP_ImitatedNPCData,
    LP_LimitedNPCDisableInfo,
    LP_MonsterBookSetCard,
    LP_MonsterBookSetCover,
    LP_HourChanged,
    LP_MiniMapOnOff,
    LP_ConsultAuthkeyUpdate,
    LP_ClassCompetitionAuthkeyUpdate,
    LP_WebBoardAuthkeyUpdate,
    LP_SessionValue,
    LP_PartyValue,
    LP_FieldValue,
    LP_BonusExpRateChanged,
    LP_FamilyChartResult,
    LP_FamilyInfoResult,
    LP_FamilyResult,
    LP_FamilyJoinRequest,
    LP_FamilyJoinRequestResult,
    LP_FamilyJoinAccepted,
    LP_FamilyPrivilegeList,
    LP_FamilyFamousPointIncResult,
    LP_FamilyNotifyLoginOrLogout,
    LP_FamilySetPrivilege,
    LP_FamilySummonRequest,
    LP_NotifyLevelUp,
    LP_NotifyWedding,
    LP_NotifyJobChange,
    LP_SetBuyEquipExt,
    LP_SetPassenserRequest,
    LP_ScriptProgressMessageBySoul,
    LP_ScriptProgressMessage,
    LP_ScriptProgressItemMessage,
    LP_SetStaticScreenMessage,
    LP_OffStaticScreenMessage,
    LP_WeatherEffectNotice,
    LP_WeatherEffectNoticeY,
    LP_ProgressMessageFont,
    LP_DataCRCCheckFailed,
    LP_ShowSlotMessage,
    LP_WildHunterInfo,
    LP_ZeroInfo,
    LP_ZeroWP,
    LP_OpenUICreatePremiumAdventurer,
    LP_ResultInstanceTable,
    LP_ItemPotChange,
    LP_ItemCoolTimeChange,
    LP_SetAdDisplayInfo,
    LP_SetSonOfLinkedSkillResult,
    LP_DojangRanking,
    UPDATE_INNER_ABILITY,
    LP_ResultSetStealSkill,
    INNER_ABILITY_MSG,
    LP_StartNavigationRequest,
    LP_FuncKeySetByScript,
    LP_CharacterPotentialSet,
    LP_CharacterPotentialReset,
    LP_CharacterHonorExp,
    LP_AswanStateInfo,
    LP_AswanResult,
    LP_ReadyForRespawn,
    LP_CharacterHonorGift,
    LP_CrossHunterCompleteResult,
    LP_CrossHunterShopResult,
    LP_UserUseNaviFlyingResult,
    LP_MapleStyleResult,
    LP_SetMaplePoint,
    LP_DressUpInfoModified,
    LP_ResetOnStateForOnOffSkill,
    LP_SetOffStateForOnOffSkill,
    LP_IssueReloginCookie,
    LP_EvolvingResult,
    LP_ActionBarResult,
    LP_GuildSearchResult,
    LP_CheckProcess,
    LP_AvatarMegaphoneRes,
    LP_AvatarMegaphoneUpdateMessage,
    LP_AvatarMegaphoneClearMessage,
    LP_RequestEventList,
    LP_LikePoint,
    LP_EventNameTagInfo,
    LP_JobFreeChangeResult,
    LP_CashShopPreviewInfo,
    LP_PendantSlotIncResult,
    LP_BossArenaMatchSucess,
    LP_BossArenaMatchFail,
    LP_BossArenaMatchRequestDone,
    LP_EliteMobWorldMapNotice,
    LP_EquipmentEnchantDisplay,
    LP_TopTowerRankResult,
    LP_FriendTowerRankResult,
    LP_TowerResultUIOpen,
    LP_ReturnToTitle,
    LP_ReturnToCharacterSelect,
    LP_FlameWizardFlameWalkEffect,
    LP_FlameWizardFlareBlink,
    NAME_CHANGE,
    SELECT_SLEIGH,
    PAM_SONG,
    MAPLE_FEED_AUTHEN,
    QUICK_PAIR_RESULT,
    GIFTS_BALL,
    DRAGON_BALL,
    TREASURE_BOX,
    GM_POLICE,
    NEW_YEAR_CARD,
    RANDOM_MORPH,
    DISPOSITION_TEXT,
    CHAIR_EXP_MSG,
    AUTO_CC_MSG,
    REWARD,
    PUZZLE_INFO,
    SHIMMER_CUBE_RESPONSE,
    CHANGE_DAMAGE_SKIN_RESPONSE,
    SAVE_DAMAGE_SKIN_RESPONSE,
    REMOVE_DAMAGE_SKIN_RESPONSE,
    LP_MacroSysDataInit,
    LP_SetField,
    LP_SetFarmField,
    MTS_OPEN,
    LP_SetCashShop,
    LP_SetCashShopInfo,
    LP_TransferFieldReqIgnored,
    LP_TransferChannelReqIgnored,
    LP_TransferPvpReqIgnored,
    LP_FieldSpecificData,
    LP_GroupMessage,
    LP_FieldUniverseMessage,
    LP_Whisper,
    LP_MobSummonItemUseResult,
    LP_FieldEffect,
    LP_BlowWeather,
    LP_PlayJukeBox,
    LP_AdminResult,
    LP_AdminLog,
    LP_Quiz,
    LP_Desc,
    LP_Clock,
    LP_CONTIMOVE,
    LP_CONTISTATE,
    LP_SetQuestClear,
    LP_DestroyClock,
    LP_ShowArenaResult,
    LP_StalkResult,
    LP_MassacreIncGauge,
    LP_MassacreResult,
    LP_QuickslotMappedInit,
    LP_FootHoldMove,
    LP_PvPStatusResult,
    LP_InGameCurNodeEventEnd,
    LP_ForceAtomCreate,
    LP_SetAchieveRate,
    LP_SetQuickMoveInfo,
    LP_ObtacleAtomCreate,
    LP_UserEnterField,
    LP_UserLeaveField,
    LP_UserChat,
    LP_UserADBoard,
    LP_UserMiniRoomBalloon,
    LP_UserConsumeItemEffect,
    LP_UserItemUpgradeEffect,
    SHOW_ENCHANTER_EFFECT,
    SHOW_SOULSCROLL_EFFECT,
    SHOW_MAGNIFYING_EFFECT,
    SHOW_POTENTIAL_EXPANSION,
    SHOW_POTENTIAL_RESET,
    SHOW_BONUS_POTENTIAL_RESET,
    SHOW_FIREWORKS_EFFECT,
    SHOW_NEBULITE_EFFECT,
    SHOW_FUSION_EFFECT,
    LP_UserHitByUser,
    LP_UserDotByUser,
    LP_UserResetAllDot,
    LP_UserDamageByUser,
    LP_UserTeslaTriangle,
    SUMMON_TEAM,
    LP_UserFollowCharacter,
    LP_UserShowPQReward,
    LP_UserSetOneTimeAction,
    LP_UserMakingSkillResult,
    LP_UserMakingMeisterSkillEff,
    LP_UserGatherResult,
    LP_UserHitByCounter,
    LP_PyramidLethalAttack,
    LP_UserMixerResult,
    LP_UserWaitQueueReponse,
    LP_UserSetDamageSkin,
    LP_UserSetDamageSkin_Premium,
    LP_UserSitResult,
    LP_FamiliarOperation,
    EFFECT_SWITCH_RESPONSE,
    LP_PetActivated,
    LP_PetMove,
    LP_PetActionSpeak,
    LP_PetNameChanged,
    LP_PetLoadExceptionList,
    LP_PetHueChanged,
    LP_PetSizeChange,
    LP_PetModified,
    LP_PetActionCommand,
    LP_DragonEnterField,
    LP_DragonMove,
    LP_DragonLeaveField,
    LP_AndroidEnterField,
    LP_AndroidMove,
    LP_AndroidActionSet,
    LP_AndroidModified,
    LP_AndroidLeaveField,
    LP_FoxManEnterField,
    LP_FoxManExclResult,
    LP_FoxManShowChangeEffect,
    LP_FoxManModified,
    LP_FoxManLeaveField,
    LP_SkillPetMove,
    LP_SkillPetAction,
    LP_SkillPetState,
    LP_SkillPetTransferField,
    LP_UserMove,
    LP_UserMeleeAttack,
    LP_UserShootAttack,
    LP_UserMagicAttack,
    LP_UserBodyAttack,
    LP_UserSkillPrepare,
    LP_UserMovingShootAttackPrepare,
    LP_UserSkillCancel,
    LP_UserHit,
    LP_UserEmotion,
    LP_AndroidEmotion,
    LP_UserSetActiveEffectItem,
    LP_UserSetActiveNickItem,
    LP_UserSetDefaultWingItem,
    LP_UserSetActivePortableChair,
    LP_UserAvatarModified,
    LP_UserEffectRemote,
    LP_UserTemporaryStatSet,
    LP_UserTemporaryStatReset,
    LP_UserHP,
    LP_UserGuildNameChanged,
    LP_UserGuildMarkChanged,
    LP_UserPvPTeamChanged,
    LP_GatherActionSet,
    LP_UpdatePvPHPTag,
    LP_DestroyGrenade,
    LP_ZeroTag,
    LP_SetMoveGrenade,
    LP_ThrowGrenade,
    LP_UserEmotionLocal,
    LP_AndroidEmotionLocal,
    LP_UserEffectLocal,
    LP_UserTeleport,
    LP_MesoGive_Succeeded,
    LP_MesoGive_Failed,
    LP_UserQuestResult,
    LP_NotifyHPDecByField,
    LP_UserPetSkillChanged,
    LP_UserBalloonMsg,
    LP_PlayEventSound,
    LP_PlayMinigameSound,
    LP_UserMakerResult,
    LP_UserOpenUI,
    LP_UserOpenUIWithOption,
    LP_SetDirectionMode,
    LP_SetInGameDirectionMode,
    LP_SetStandAloneMode,
    LP_UserHireTutor,
    LP_UserTutorMsg,
    LP_UserHireTutorById,
    LP_UserSetPartner,
    LP_UserSetPartnerAction,
    LP_UserSetPartnerForceFlip,
    LP_UserSwitchRP,
    LP_ModCombo,
    LP_IncComboByComboRecharge,
    LP_UserNoticeMsg,
    LP_UserChatMsg,
    LP_UserBuffzoneEffect,
    LP_UserTimeBombAttack,
    LP_UserExplosionAttack,
    LP_UserPassiveMove,
    LP_UserFollowCharacterFailed,
    LP_CreateNewCharacterResult_PremiumAdventurer,
    LP_GatherRequestResult,
    LP_RuneStoneUseAck,
    LP_UserBagItemUseResult,
    LP_RandomTeleportKey,
    LP_SetGagePoint,
    LP_UserInGameDirectionEvent,
    LP_MedalReissueResult,
    LP_UserPlayMovieClip,
    LP_UserPlayMovieClipURL,
    LP_IncJudgementStack,
    LP_IncCharmByCashPRMsg,
    LP_SetBuffProtector,
    LP_ChangeLarknessStack,
    LP_DetonateBomb,
    LP_AggroRankInfo,
    LP_DeathCountInfo,
    LP_IndividualDeathCountInfo,
    LP_UserFlipTheCoinEnabled,
    LP_OpenUIOnDead,
    LP_ExpiredNotice,
    LP_UserSitOnTimeCapsule,
    LP_UserFinalAttackRequest,
    LP_UserSetGun,
    LP_UserSetAmmo,
    LP_UserCreateGun,
    LP_UserClearGun,
    LP_MirrorDungeonRecord,
    LP_UserOpenURL,
    LP_ZeroCombatRecovery,
    LP_MirrorStudyUIOpen,
    LP_MirrorReadingUIOpen,
    LP_ZeroLevelUpAlram,
    LP_IsUniverse,
    LP_DoActiveEventSkillByScript,
    LP_RuneStoneSkillAck,
    LP_ResetRuneStoneAction,
    LP_PlayAmbientSound,
    LP_StopAmbientSound,
    SETP_GIFT_ID,
    LP_BossPartyCheckDone,
    LP_FreeLookChangeUIOpen,
    LP_FreeLookChangeSuccess,
    LP_GrayBackground,
    SETP_COIN,
    IMPERIAL_BODY_DESTORY,
    FLASH_CUBE_RESPONSE,
    LP_OpenBingo,
    LP_CameraSwitch,
    LP_UserSetFieldFloating,
    LP_AddPopupSay,
    LP_RemovePopupSay,
    LP_JaguarSkill,
    LP_ActionLayerRelmove,
    LP_SendClientResolution,
    LP_UserBonusAttackRequest,
    LP_UserRandAreaAttackRequest,
    LP_JaguarActive,
    LP_SetSlownDown,
    HAYATO_JIAN_QI,
    LP_SkillCooltimeSet,
    LP_SummonedEnterField,
    LP_SummonedLeaveField,
    LP_SummonedMove,
    LP_SummonedAttack,
    LP_SummonedAttackPvP,
    LP_SummonedSetReference,
    LP_SummonedSkill,
    LP_SummonedSkillPvP,
    LP_SummonedHPTagUpdate,
    LP_SummonedAssistAttackRequest,
    LP_SummonedAttackActive,
    LP_MobEnterField,
    LP_MobLeaveField,
    LP_MobChangeController,
    LP_MobMove,
    LP_MobCtrlAck,
    LP_MobStatSet,
    LP_MobStatReset,
    LP_MobSuspendReset,
    LP_MobAffected,
    LP_MobDamaged,
    LP_MobSpecialEffectBySkill,
    LP_MobCrcKeyChanged,
    LP_MobHPIndicator,
    LP_MobCatchEffect,
    LP_MobEffectByItem,
    LP_MobSpeaking,
    LP_MobMessaging,
    LP_MobSkillDelay,
    LP_MobRequestResultEscortInfo,
    LP_MobEscortStopEndPermmision,
    LP_MobEscortStopByScript,
    LP_MobEscortStopSay,
    LP_MobEscortReturnBefore,
    LP_MobNextAttack,
    LP_MobAttackedByMob,
    LP_MinionEnterField,
    LP_MinionLeaveField,
    LP_MinionChangeController,
    LP_MinionGenBeyondSplit,
    LP_NpcEnterField,
    LP_NpcLeaveField,
    LP_NpcChangeController,
    LP_NpcMove,
    LP_NpcUpdateLimitedInfo,
    LP_NpcCharacterBaseAction,
    LP_NpcSpecialAction,
    LP_NpcSetScript,
    LP_EmployeeEnterField,
    LP_EmployeeLeaveField,
    UPDATE_HIRED_MERCHANT,
    CHANGE_HIRED_MERCHANT_NAME,
    LP_DropEnterField,
    LP_DropLeaveField,
    LP_CreateMessgaeBoxFailed,
    LP_MessageBoxEnterField,
    LP_MessageBoxLeaveField,
    LP_AffectedAreaCreated,
    LP_MobSkillInstalledFire,
    LP_AffectedAreaRemoved,
    LP_TownPortalCreated,
    LP_TownPortalRemoved,
    LP_OpenGateCreated,
    LP_OpenGateClose,
    LP_OpenGateRemoved,
    LP_ReactorChangeState,
    LP_ReactorMove,
    LP_ReactorEnterField,
    LP_ReactorStateReset,
    LP_ReactorOwnerInfo,
    LP_ReactorRemove,
    LP_ReactorLeaveField,
    LP_DecomposerEnterField,
    LP_DecomposerLeaveField,
    LP_SnowBallState,
    LP_SnowBallHit,
    LP_SnowBallMsg,
    LP_SnowBallTouch,
    LP_CoconutHit,
    LP_CoconutScore,
    LP_HealerMove,
    LP_PulleyStateChange,
    LP_MCarnivalEnter,
    LP_MCarnivalPersonalCP,
    LP_MCarnivalTeamCScore,
    LP_MCarnivalSpellCooltime,
    LP_MCarnivalResultSuccess,
    LP_MCarnivalResultFail,
    LP_MCarnivalDeath,
    LP_MCarnivalMemberOut,
    LP_MCarnivalGameResult,
    LP_MCarnivalUpdateRankInfo,
    LP_ArenaScore,
    LP_BattlefieldEnter,
    LP_BattlefieldScore,
    LP_BattlefieldTeamChanged,
    LP_WitchtowerScore,
    LP_BossSummonTimer,
    LP_PVPFieldEnter,
    LP_PVPTeamChange,
    LP_PVPModeChange,
    LP_PVPStateChange,
    LP_PVPUpdateCount,
    LP_PVPModeResult,
    LP_PVPUpdateTeamInfo,
    LP_PVPUpdateRankInfo,
    LP_PVPTeamScore,
    LP_PVPReviveMessage,
    LP_PVPScreenEffect,
    LP_PVPIceKnightHPChange,
    LP_RuneStoneClearAndAllRegister,
    LP_RuneStoneDisappear,
    LP_RuneStoneAppear,
    CHAOS_ZAKUM_SHRINE,
    HORNTAIL_SHRINE,
    CS_MESO_UPDATE,
    CS_COLLOCATTON,
    CAPTURE_FLAGS,
    CAPTURE_POSITION,
    CAPTURE_RESET,
    LP_ZakumTimer,
    CreatePsychicLock,
    RecreatePathPsychicLcok,
    ReleasePsychicLock,
    ReleasePsychicLockMob,
    CreatePsychicArea,
    ReleasePsychicArea,
    LP_ScriptMessage,
    LP_OpenShopDlg,
    LP_ShopResult,
    LP_AdminShopResult,
    LP_AdminShopCommodity,
    LP_TrunkResult,
    LP_StoreBankGetAllResult,
    LP_StoreBankResult,
    LP_RPSGame,
    LP_Messenger,
    LP_MiniRoom,
    LP_Tournament,
    LP_TournamentMatchTable,
    LP_TournamentSetPrize,
    LP_TournamentNoticeUEW,
    LP_TournamentAvatarInfo,
    LP_WeddingProgress,
    LP_WeddingCremonyEnd,
    LP_Parcel,
    LP_PoloFritoBountyHuntingStage,
    LP_PoloFritoTownDefenseWave,
    LP_PoloFritoTownDefenseLife,
    LP_PoloFritoCourtshipDanceState,
    LP_PoloFritoCourtshipDanceCommand,
    LP_FieldRandomStigmaIncinerate,
    LP_FieldStigmaObjectDec,
    LP_DemianFlyingSwordCreate,
    LP_DemianFlyingSwordMakeEnterRequest,
    LP_DemianFlyingSwordMakeEnterInfo,
    LP_DemianFlyingSwordNode,
    LP_DemianFlyingSwordTarget,
    LP_DemianCorruption,
    LP_LucidButterflyCreate,
    LP_LucidButterflyAction,
    LP_LucidDragonCreate,
    LP_LucidUseSkill,
    LP_LucidStainedGlassOnOff,
    LP_LucidStainedGlassBreak,
    LP_LucidStatueStateChange,
    LP_LucidSetFlyingMode,
    LP_LucidWelcomBarrage,
    LP_GhostParkRuneUseAck,
    LP_GhostParkRuneAppear,
    LP_GhostParkRuneDisappear,
    LP_GhostParkSetKilledMobExpRate,
    LP_GhostParkSetCurseLevelExpRate,
    LP_GhostParkHomingBulletCreate,
    LP_CashShopChargeParamResult,
    LP_CashShopQueryCashResult,
    LP_CashShopCashItemResult,
    LP_CashShopPurchaseExpChanged,
    LP_CashCoodinaionResult,
    LP_EventUIData,
    LP_EventUIAck,
    LP_GhostPaintsPointUpdate,
    LP_UserTimerInfo,
    LP_ContentsMap,
    LP_UrusShop,
    LP_FuncKeyMappedInit,
    LP_PetConsumeItemInit,
    LP_PetConsumeMPItemInit,
    PET_AUTO_CURE,
    LP_CheckSPWOnCreateNewCharacterResult,
    LP_GoldHammerResult,
    LP_PlatinumHammerResult,
    LP_EgoEquipGaugeCompleteReturn,
    LP_EgoEquipCreateUpgradeItemCostInfo,
    LP_EgoEquipCheckUpgradeItemResult,
    LP_InheritanceInfo,
    LP_InheritanceComplete,
    LP_FIELDATTACKOBJ_CREATE,
    LP_FIELDATTACKOBJ_REMOVE_BYLIST,
    LP_FIELDATTACKOBJ_SETATTACK,
    LP_DamageSkinSaveResult,
    STRENGTHEN_UI,
    LEVEL_UI,
    DAY_OF_CHRONOSPHERE,
    ERROR_CHRONOSPHERE,
    BINGO_CARD,
    BINGO_BALL_CALL,
    BINGO_RESPONSE,
    BINGO_RANKING,
    BINGO_UNK,
    BINGO_RESULT,
    BINGO_MARK,
    BINGO_UI,
    UNKNOWN,
    AUTH_RESPONSE,
    GUEST_ID_LOGIN,
    SEND_LINK,
    PIN_OPERATION,
    PIN_ASSIGNED,
    ALL_CHARLIST,
    RELOG_RESPONSE,
    REGISTER_PIC_RESPONSE,
    EXTRA_CHAR_INFO,
    SPECIAL_CREATION,
    FULL_CLIENT_DOWNLOAD,
    BOOK_INFO,
    REPORT_RESULT,
    TRADE_LIMIT,
    UPDATE_GENDER,
    BBS_OPERATION,
    CODEX_INFO_RESPONSE,
    ECHO_MESSAGE,
    BOOK_STATS,
    UPDATE_CODEX,
    CARD_DROPS,
    FAMILIAR_INFO,
    POTION_BONUS,
    MAPLE_TV_MSG,
    POPUP2,
    CANCEL_NAME_CHANGE,
    CANCEL_WORLD_TRANSFER,
    CLOSE_HIRED_MERCHANT,
    CANCEL_NAME_CHANGE_2,
    GM_STORY_BOARD,
    FIND_FRIEND,
    VISITOR,
    PINKBEAN_CHOCO,
    EQUIP_STOLEN_SKILL,
    INNER_ABILITY_RESET_MSG,
    CASSANDRAS_COLLECTION,
    SET_OBJECT_STATE,
    POPUP,
    YOUR_INFORMATION,
    CANDY_RANKING,
    ATTENDANCE,
    RANDOM_RESPONSE,
    MAGIC_WHEEL,
    MOVE_ENV,
    UPDATE_ENV,
    CHATTEXT_1,
    SPAWN_PET_2,
    SPAWN_FAMILIAR,
    MOVE_FAMILIAR,
    TOUCH_FAMILIAR,
    ATTACK_FAMILIAR,
    RENAME_FAMILIAR,
    SPAWN_FAMILIAR_2,
    UPDATE_FAMILIAR,
    R_MESOBAG_SUCCESS,
    R_MESOBAG_FAILURE,
    MAP_FADE,
    MAP_FADE_FORCE,
    RANDOM_EMOTION,
    RADIO_SCHEDULE,
    OPEN_SKILL_GUIDE,
    AP_SP_EVENT,
    QUEST_GUIDE_NPC,
    REGISTER_FAMILIAR,
    FAMILIAR_MESSAGE,
    SHOW_MAP_NAME,
    CAKE_VS_PIE,
    MOVE_SCREEN_X,
    MOVE_SCREEN_DOWN,
    CAKE_PIE_INSTRUMENTS,
    SEALED_BOX,
    MONSTER_PROPERTIES,
    CYGNUS_ATTACK,
    MONSTER_RESIST,
    TELE_MONSTER,
    SHOW_MAGNET,
    NPC_TOGGLE_VISIBLE,
    INITIAL_QUIZ,
    RED_LEAF_HIGH,
    LOGOUT_GIFT,
    CS_CHARGE_CASH,
    GIFT_RESULT,
    CHANGE_NAME_CHECK,
    CHANGE_NAME_RESPONSE,
    CASH_SHOP_UPDATE,
    GACHAPON_STAMPS,
    FREE_CASH_ITEM,
    CS_SURPRISE,
    XMAS_SURPRISE,
    ONE_A_DAY,
    NX_SPEND_GIFT,
    RECEIVE_GIFT,
    RANDOM_CHECK,
    START_TV,
    REMOVE_TV,
    ENABLE_TV,
    GM_ERROR,
    ALIEN_SOCKET_CREATOR,
    BATTLE_RECORD_DAMAGE_INFO,
    CALCULATE_REQUEST_RESULT,
    BOOSTER_PACK,
    BOOSTER_FAMILIAR,
    BLOCK_PORTAL,
    NPC_CONFIRM,
    RSA_KEY,
    BUFF_BAR,
    GAME_POLL_REPLY,
    GAME_POLL_QUESTION,
    ENGLISH_QUIZ,
    FISHING_BOARD_UPDATE,
    BOAT_EFFECT,
    FISHING_CAUGHT,
    SIDEKICK_OPERATION,
    FARM_PACKET1,
    FARM_ITEM_PURCHASED,
    FARM_ITEM_GAIN,
    HARVEST_WARU,
    FARM_MONSTER_GAIN,
    FARM_INFO,
    FARM_MONSTER_INFO,
    FARM_QUEST_DATA,
    FARM_QUEST_INFO,
    FARM_MESSAGE,
    UPDATE_MONSTER,
    AESTHETIC_POINT,
    UPDATE_WARU,
    FARM_EXP,
    FARM_PACKET4,
    QUEST_ALERT,
    FARM_PACKET8,
    FARM_FRIENDS_BUDDY_REQUEST,
    FARM_FRIENDS,
    FARM_USER_INFO,
    FARM_AVATAR,
    FRIEND_INFO,
    FARM_RANKING,
    SPAWN_FARM_MONSTER1,
    SPAWN_FARM_MONSTER2,
    RENAME_MONSTER,
    REDIRECTOR_COMMAND,
    LP_VMatrixUpdate,
    LP_VCoreGemstoneDialog,
    LP_VCoreDecomeposeResultDialog,
    LP_VMatrixEnhanceResultDialog,
    LP_VMatrixCraftResultDialog,
    LP_VCoreExpired,;

    public static boolean record = false;

    static {
        loadValues();
    }

    private short code;

    private SendPacketOpcode() {
        this.code = 0x7FFE;
    }

    private SendPacketOpcode(short code) {
        this.code = code;
    }

    public static String nameOf(int value) {
        for (SendPacketOpcode opcode : SendPacketOpcode.values()) {
            if (opcode.getValue(false) == value) {
                return opcode.name();
            }
        }
        return "UNKNOWN";
    }

    public static boolean isRecordHeader(SendPacketOpcode opcode) {
        switch (opcode.name()) {
//            case "LP_SetField":
//            case "LP_GuildResult":
//            case "LP_PartyResult":
//            case "LP_TemporaryStatSet":
//            case "LP_VMatrixShardUpdate":
//            case "LP_UserEnterField":
//            case "LP_DropEnterField":
//            case "LP_InventoryOperation":
//            case "LP_MobEnterField":
//            case "LP_SetCashShopInfo":
//                return true;
            default:
                return false;
        }
    }

    public static boolean isSpamHeader(SendPacketOpcode opcode) {
        switch (opcode.name()) {
            case "SHOW_MAPLESTORY":
//            case "LP_SetWeekEventMessage":
//            case "LP_AliveReq":
            case "LP_SetField":
            case "LP_NpcMove":
//            case "AUTH_RESPONSE":
//            case "LP_WorldInformation":
            case "LP_StatChanged":
//            case "LP_UserMove":
//            case "LP_NpcEnterField":
//            case "LP_NpcChangeController":
//            case "LP_NpcLeaveField":
//            case "LP_MobMove":
            case "LP_MobCtrlAck":
//            case "LP_MobEnterField":
//            case "LP_MobChangeController":
            case "LP_UserChatMsg":
//            case "LP_SkillPetMove":
//            case "LP_SummonedMove":
//            case "LP_SummonedLeaveField":
//            case "LP_AndroidMove":
//            case "LP_InventoryOperation":
            case "LP_PetMove":
//            case "LP_UserEffectLocal":
//            case "LP_DropEnterField":
//            case "LP_DropLeaveField":
//            case "LP_UserHP":
//            case "LP_UserHit":
//            case "LP_MobHPIndicator":
//            case "LP_BroadcastMsg":
//            case "LP_UserMeleeAttack":
//            case "LP_UserShootAttack":
//            case "LP_ModCombo":
//            case "REMOVE_BG_LAYER":
//            case "LP_ResultInstanceTable":
            case "LP_ScriptProgressMessage":
//            case "LP_UserSetDefaultWingItem":
//            case "LP_UserAvatarModified":
//            case "LP_MobLeaveField":
//            case "LP_CheckProcess":
                return true;
            default:
                return false;
        }
    }

    public static void loadValues() {
        String fileName = "sendops.properties";
        Properties props = new Properties();
        try (FileInputStream fileInputStream = new FileInputStream(fileName);
                BufferedReader br = new BufferedReader(
                        new InputStreamReader(fileInputStream, StringUtil.codeString(fileName)))) {
            props.load(br);
        } catch (IOException ex) {
            InputStream in = SendPacketOpcode.class.getClassLoader().getResourceAsStream("properties/" + fileName);
            if (in == null) {
                System.out.println("錯誤: 未加載 " + fileName + " 檔案");
                return;
            }
            try {
                props.load(in);
                in.close();
            } catch (IOException e) {
                throw new RuntimeException("加載 " + fileName + " 檔案出錯", e);
            }
        }
        ExternalCodeTableGetter.populateValues(props, values());
    }

    @Override
    public short getValue() {
        return getValue(true);
    }

    @Override
    public void setValue(short code) {
        this.code = code;
    }

    public short getValue(boolean show) {
        if (show && ServerConfig.LOG_PACKETS) {
            if (isRecordHeader(this)) {
                record = true;
                String tab = "";
                for (int i = 4; i > name().length() / 8; i--) {
                    tab += "\t";
                }
                FileoutputUtil.log(FileoutputUtil.Packet_Record, "[LP]\t" + name() + tab + "\t包頭:0x"
                        + StringUtil.getLeftPaddedStr(String.valueOf(code), '0', 4) + "\r\n");
            } else {
                record = false;
            }
        }
        return code;
    }

    public String getType(short code) {
        String type = null;
        if (code >= 0 && code < 0xE || code >= 0x17 && code < 0x21) {
            type = "CLogin";
        } else if (code >= 0xE && code < 0x17) {
            type = "LoginSecure";
        } else if (code >= 0x21 && code < 0xCB) {
            type = "CWvsContext";
        } else if (code >= 0xD2) {
            type = "CField";
        }
        return type;
    }
}
